home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / multibox.sty < prev    next >
Text File  |  1989-12-21  |  2KB  |  64 lines

  1. % MULTIBOX.STY - a style option to provide multiple boxes in pictures
  2. % ============
  3. % Author: Brian HAMILTON KELLY, Royal Military College of Science,
  4. %                               Shrivenham, SWINDON, SN6 8LA, United Kingdom
  5. % Date:   13 October 1988
  6. %
  7. % This style file option provides two new commands for use in the picture
  8. % environment:
  9. %
  10. % \multimake(x,y)(dx,dy){n}(w,h)[<pos>]{Text_1}{Text_2}...{Text_n}
  11. % \multiframe(x,y)(dx,dy){n}(w,h)[<pos>]{Text_1}{Text_2}...{Text_n}
  12. %
  13. % These commands set the n texts Text_1..Text_n inside a \makebox or
  14. % \framebox respectively.  The first box has its lower-left corner at (x,y),
  15. % and successive boxes are located at (x+dx,y+dy),..,(x+(n-1)dx,y+(n-1)dy).
  16. % Each box has width and height determined by (w,h), and the optional
  17. % box placement parameter <pos> is applied to all the generated texts
  18. %
  19.  
  20. \newtoks\multi@rg
  21.  
  22. \def\multiframe{\let\@putitem=\@iframepicbox \multib@x}
  23. \def\multimake{\let\@putitem=\@imakepicbox \multib@x}
  24.  
  25. \def\multib@x(#1,#2)(#3,#4)#5(#6,#7){\@xdim=#1\unitlength \@ydim=#2\unitlength
  26.   \def\@dxdim{#3} \def\@dydim{#4}
  27.   \@multicnt=#5 \def\@Xsize{#6} \def\@Ysize{#7}
  28.   \@ifnextchar [{\imultib@x}{\imultib@x[]}
  29.   }
  30.  
  31. % The liberal use of % at the ends of lines is to prevent the ingestion of
  32. % superfluous spaces which would otherwise upset the horizontal positioning
  33. % of the boxes.
  34.  
  35. \def\imultib@x[#1]{\@killglue\relax
  36.   \def\p@sarg{#1}%
  37.   \d@multi
  38.   }
  39.  
  40. % We need the expanded definition of \i@putitem because \@imakepicbox DOESN'T
  41. % expand its #3 argument (the optional text placement bit).  However, it can
  42. % only recognize the letters b, t, l and r in this position, so \p@sarg is no
  43. % use.  Therefore we expand the arguments, producing an appropriate call.
  44.  
  45. \def\d@multi{%
  46.   \ifnum\@multicnt > 0
  47.     \def\next@rg##1{%
  48.       \multi@rg={{##1}}% Assign the next argument of original text to \multi@rg
  49.       \edef\@iputitem{%
  50.     \noexpand\@putitem(\@Xsize,\@Ysize)[\p@sarg]{\the\multi@rg}%
  51.       }%
  52.       \raise\@ydim\hbox to \z@{\kern \@xdim \@iputitem\hss}%
  53.       \advance\@xdim by \@dxdim\unitlength \advance\@ydim by \@dydim\unitlength
  54.       \advance\@multicnt by \m@ne
  55.       \d@multi}% End of (re-)definition of \next@rg
  56.   \else
  57.     \let\next@rg=\ignorespaces
  58.   \fi      % Now execute \next@rg;
  59.   \next@rg % This will read the text, set it and then call \d@multi recursively
  60.   }
  61.  
  62.  
  63.  
  64.